package com.jinxixin.android.recordvideo.util;

/**
 * @Description: 时间工具类
 * @Author: ivan
 * @CreateDate: 2020/5/23 10:05 AM
 */
public class TimeUtils {
    //将毫秒转换成00:00:00
    public static String formatLongToTimeStr(long a) {
        try {
            int hour = 0;
            int minute = 0;
            int second = 0;

            second = (int) (a / 1000);

            if (second > 60) {
                minute = second / 60;
                second = second % 60;
            }
            if (minute > 60) {
                hour = minute / 60;
                minute = minute % 60;
            }
            String newHour = "";
            if (hour < 10) {
                newHour = "0" + hour;
            } else {
                newHour = hour + "";
            }
            String newMinute = "";
            if (minute < 10) {
                newMinute = "0" + minute;
            } else {
                newMinute = minute + "";
            }
            String newSecond = "";
            if (second < 10) {
                newSecond = "0" + second;
            } else {
                newSecond = second + "";
            }
            return (newHour + ":" + newMinute + ":"
                    + newSecond);
        } catch (Exception e) {
            e.printStackTrace();
            return "00:00:00";
        }
    }
}
